#! /bin/bash

# echo 92  > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio92/direction
# echo 87  > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio87/direction
# echo 83  > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio83/direction
# echo 0   > /sys/class/gpio/gpio92/value
# echo 1   > /sys/class/gpio/gpio87/value
# echo 1   > /sys/class/gpio/gpio83/value


# IO_RST_GPRS_Ct                      IO_PW_GPRS_Ct                       IO_GPRSPWR_CT
# GPRS复位脚                          GPRS电源连接模块芯片                  GPRS模块供电电源		
# MX6UL_PAD_LCD_DATA23__GPIO3_IO28	MX6UL_PAD_LCD_DATA18__GPIO3_IO23	MX6UL_PAD_LCD_DATA14__GPIO3_IO19
# 92	                                87	                                83


io_rst="92"
io_switch="87"
io_power="83"

io_rst_val="/sys/class/gpio/gpio"$io_rst"/value"
io_switch_val="/sys/class/gpio/gpio"$io_switch"/value"
io_power_val="/sys/class/gpio/gpio"$io_power"/value"

for n in $io_rst $io_switch $io_power
do
    echo $n > /sys/class/gpio/unexport 
    echo $n > /sys/class/gpio/export
    echo out > "/sys/class/gpio/gpio"$n"/direction"
done



power_down(){
    echo 0   > $io_rst_val
    echo 1   > $io_switch_val
    echo 0   > $io_power
}

power_switch(){
    echo 0   > $io_rst_val
    echo 0   > $io_power

    echo 0   > $io_switch_val
    sleep 1
    echo 1   > $io_switch_val
}


power_on(){
    echo 0   > $io_rst_val
    echo 1   > $io_switch_val
    echo 1   > $io_power_val
}

# 没有参数 =on
echo usage:$0 [on/off]
if [ $# == 0 ] ||  [ $1 == "on" ]
then
   echo power_on
   power_on
else
   echo power_down
   power_down
fi